<template>
	<u-upload
		:deletable="false"
		:fileList="getFileList()"
		:previewFullImage="true"
		:maxCount="fileList.length"
		:width="width + 'rpx'"
		:height="height + 'rpx'"
	></u-upload>
</template>

<script>
	import {apiUrl_config} from '@/config.js'
	export default {
		props: {
			fileList: {
				type: Array,
				default: () => {return []}
			},
			single: {
				type: Boolean,
				default: () => {return false}
			},
			width: {
				type: Number,
				default: () => {return 80}
			},
			height: {
				type: Number,
				default: () => {return 80}
			},
		},
		data() {
			return {
				baseUrl: apiUrl_config
			};
		},
		methods: {
			getFileList(){
				let _self = this
				let list = JSON.parse(JSON.stringify(_self.fileList))
				list.forEach(item => {
					item.url = `${_self.baseUrl}${item.path || item.url}`
					item.path && delete item.path
				})
				// console.log(list)
				if(_self.single) return list[0]
				return list
			},
		}
	}
</script>

<style lang="scss" scoped></style>
